package com.shierke.Ume.ui.adapter.explore

import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import com.bumptech.glide.Glide
import com.bumptech.glide.load.resource.bitmap.CircleCrop
import com.bumptech.glide.request.RequestOptions
import com.shierke.Ume.R
import kotlinx.android.synthetic.main.item_explore_user_follow.view.*

/**
 * Create by Ybx
 * on 2020-10-16
 * Desribe:
 */
class ExploreUserFollowerAdpter : RecyclerView.Adapter<ExploreUserFollowerAdpter.ViewHolder>() {
    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {


        val view = LayoutInflater.from(parent.context)
            .inflate(R.layout.item_explore_user_follow, null, false)
        return ViewHolder(view)
    }

    override fun getItemCount() = 10

    override fun onBindViewHolder(holder: ViewHolder, position: Int) {
        holder.onBind(position)
    }


    class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {

        fun onBind(position: Int) {


            with(itemView) {

                Glide.with(this)
                    .load(R.mipmap.search_result_head)
                    .apply(RequestOptions.bitmapTransform(CircleCrop()))
                    .into(headImage)

                if (position % 2 == 0) {
                    follow.isSelected = false
                    follow.text = "Follow"
                } else {
                    follow.isSelected = true
                    follow.text = "Unfollow"
                }
            }
        }

    }

}
